package elion.com.theElion.fragmentSeed;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import elion.com.elion.R;
import elion.com.theElion.utils.ImageLoder;
import elion.vo.seed.Crop;


/**
 * Created by xiaon on 2017/7/16.
 */

public class SeedMainFragment extends Fragment {

    private TextView tv_name;
    private TextView tv_ladingName;
    private TextView tv_from;
    private ImageView im_image;
    private TextView tv_location;
    private TextView tv_hib;
    private TextView tv_values;

    private View mview;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mview = inflater.inflate(R.layout.fragment_seed_main, null);

        findview();
        inits();

        return mview;
    }

    public void inits() {
        Intent intent = getActivity().getIntent();
        Crop crop = intent.getParcelableExtra("seed");
        tv_name.setText(crop.getName());
        tv_ladingName.setText(crop.getLading_name());
        tv_from.setText(crop.getCategory1() + " " + crop.getCategory2());
        new ImageLoder().showImageByThread(im_image, crop.getImg_url());
        tv_location.setText(crop.getRange1());
        tv_hib.setText(crop.getGrow_habit());
        tv_values.setText(crop.getValue());

    }

    public void findview() {

        tv_name = (TextView) mview.findViewById(R.id.tv_seed_name);
        tv_ladingName = (TextView) mview.findViewById(R.id.tv_seed_ladingname);
        tv_from = (TextView) mview.findViewById(R.id.tv_seed_from);
        im_image = (ImageView) mview.findViewById(R.id.im_seed_main_image);
        tv_location = (TextView) mview.findViewById(R.id.tv_seed_location);
        tv_hib = (TextView) mview.findViewById(R.id.tv_seed_hib);
        tv_values = (TextView) mview.findViewById(R.id.tv_seed_values);
    }
}
